package com.ize.controller.student;

import com.ize.entity.pojo.Article;
import com.ize.entity.pojo.PageBean;
import com.ize.result.Result;
import com.ize.service.ArticleService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

@RestController("studentGetArticle")
@RequestMapping("/student/article")
@Slf4j
@Api(tags = "文章通知相关接口", value = "用户相关接口")
@RequiredArgsConstructor
public class ArticleController {

    private final ArticleService articleService;

    @GetMapping("/getList")
    @ApiOperation("获取文章")
    public Result<PageBean<Article>> getList(Integer page,
                                             Integer pageSize) {
        log.info("page:{},pageSize:{}", page, pageSize);
        PageBean<Article> pb = articleService.select(page,pageSize);
        return Result.success(pb);
    }

    @GetMapping("/getDetail")
    @ApiOperation("获取文章详情")
    public Result<Article> getDetail(@RequestParam Integer id) {
        log.info("文章id:{}", id);
        Article a = articleService.getDtail(id);
        return Result.success(a);
    }
}
